// MESSAGE ASCTEC_GPS PACKING

#define MAVLINK_MSG_ID_ASCTEC_GPS 2

typedef struct __mavlink_asctec_gps_t
{
 uint32_t msec; ///< Timestamp (microseconds since UNIX epoch or microseconds since system boot)
 int32_t GPS_longitude; ///< Longitude in degrees * 10^7
 int32_t GPS_height; ///< Altitude in mm
 uint32_t GPS_position_accuracy; ///< accuracy estimates in mm
 uint32_t GPS_height_accuracy; ///< accuracy estimates in mm
 int32_t GPS_speed_x; ///< speed in x (E/W) in mm/s
 int32_t GPS_speed_y; ///< speed in y (N/S) in mm/s
 int32_t GPS_heading; ///< GPS heading in deg * 1000
 uint32_t GPS_time_of_week; ///< [ms] (1 week = 604,800 s)
 uint16_t GPS_latitude; ///< Latitude in degrees * 10^7
 uint16_t GPS_week; ///< starts from beginning of year 1980
 uint8_t GPS_status; ///< GPS status information: Bit7...Bit3: 0; Bit 2: longitude direction; Bit1: latitude direction; Bit 0: GPS lock
 uint8_t GPS_sat_num; ///< number of satellites used in NAV solution
} mavlink_asctec_gps_t;

#define MAVLINK_MSG_ID_ASCTEC_GPS_LEN 42
#define MAVLINK_MSG_ID_2_LEN 42



#define MAVLINK_MESSAGE_INFO_ASCTEC_GPS { \
	"ASCTEC_GPS", \
	13, \
	{  { "msec", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_asctec_gps_t, msec) }, \
         { "GPS_longitude", NULL, MAVLINK_TYPE_INT32_T, 0, 4, offsetof(mavlink_asctec_gps_t, GPS_longitude) }, \
         { "GPS_height", NULL, MAVLINK_TYPE_INT32_T, 0, 8, offsetof(mavlink_asctec_gps_t, GPS_height) }, \
         { "GPS_position_accuracy", NULL, MAVLINK_TYPE_UINT32_T, 0, 12, offsetof(mavlink_asctec_gps_t, GPS_position_accuracy) }, \
         { "GPS_height_accuracy", NULL, MAVLINK_TYPE_UINT32_T, 0, 16, offsetof(mavlink_asctec_gps_t, GPS_height_accuracy) }, \
         { "GPS_speed_x", NULL, MAVLINK_TYPE_INT32_T, 0, 20, offsetof(mavlink_asctec_gps_t, GPS_speed_x) }, \
         { "GPS_speed_y", NULL, MAVLINK_TYPE_INT32_T, 0, 24, offsetof(mavlink_asctec_gps_t, GPS_speed_y) }, \
         { "GPS_heading", NULL, MAVLINK_TYPE_INT32_T, 0, 28, offsetof(mavlink_asctec_gps_t, GPS_heading) }, \
         { "GPS_time_of_week", NULL, MAVLINK_TYPE_UINT32_T, 0, 32, offsetof(mavlink_asctec_gps_t, GPS_time_of_week) }, \
         { "GPS_latitude", NULL, MAVLINK_TYPE_UINT16_T, 0, 36, offsetof(mavlink_asctec_gps_t, GPS_latitude) }, \
         { "GPS_week", NULL, MAVLINK_TYPE_UINT16_T, 0, 38, offsetof(mavlink_asctec_gps_t, GPS_week) }, \
         { "GPS_status", NULL, MAVLINK_TYPE_UINT8_T, 0, 40, offsetof(mavlink_asctec_gps_t, GPS_status) }, \
         { "GPS_sat_num", NULL, MAVLINK_TYPE_UINT8_T, 0, 41, offsetof(mavlink_asctec_gps_t, GPS_sat_num) }, \
         } \
}


/**
 * @brief Pack a asctec_gps message
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param msg The MAVLink message to compress the data into
 *
 * @param msec Timestamp (microseconds since UNIX epoch or microseconds since system boot)
 * @param GPS_status GPS status information: Bit7...Bit3: 0; Bit 2: longitude direction; Bit1: latitude direction; Bit 0: GPS lock
 * @param GPS_latitude Latitude in degrees * 10^7
 * @param GPS_longitude Longitude in degrees * 10^7
 * @param GPS_height Altitude in mm
 * @param GPS_position_accuracy accuracy estimates in mm
 * @param GPS_height_accuracy accuracy estimates in mm
 * @param GPS_speed_x speed in x (E/W) in mm/s
 * @param GPS_speed_y speed in y (N/S) in mm/s
 * @param GPS_heading GPS heading in deg * 1000
 * @param GPS_sat_num number of satellites used in NAV solution
 * @param GPS_time_of_week [ms] (1 week = 604,800 s)
 * @param GPS_week starts from beginning of year 1980
 * @return length of the message in bytes (excluding serial stream start sign)
 */
static inline uint16_t mavlink_msg_asctec_gps_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
						       uint32_t msec, uint8_t GPS_status, uint16_t GPS_latitude, int32_t GPS_longitude, int32_t GPS_height, uint32_t GPS_position_accuracy, uint32_t GPS_height_accuracy, int32_t GPS_speed_x, int32_t GPS_speed_y, int32_t GPS_heading, uint8_t GPS_sat_num, uint32_t GPS_time_of_week, uint16_t GPS_week)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
	char buf[42];
	_mav_put_uint32_t(buf, 0, msec);
	_mav_put_int32_t(buf, 4, GPS_longitude);
	_mav_put_int32_t(buf, 8, GPS_height);
	_mav_put_uint32_t(buf, 12, GPS_position_accuracy);
	_mav_put_uint32_t(buf, 16, GPS_height_accuracy);
	_mav_put_int32_t(buf, 20, GPS_speed_x);
	_mav_put_int32_t(buf, 24, GPS_speed_y);
	_mav_put_int32_t(buf, 28, GPS_heading);
	_mav_put_uint32_t(buf, 32, GPS_time_of_week);
	_mav_put_uint16_t(buf, 36, GPS_latitude);
	_mav_put_uint16_t(buf, 38, GPS_week);
	_mav_put_uint8_t(buf, 40, GPS_status);
	_mav_put_uint8_t(buf, 41, GPS_sat_num);

        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 42);
#else
	mavlink_asctec_gps_t packet;
	packet.msec = msec;
	packet.GPS_longitude = GPS_longitude;
	packet.GPS_height = GPS_height;
	packet.GPS_position_accuracy = GPS_position_accuracy;
	packet.GPS_height_accuracy = GPS_height_accuracy;
	packet.GPS_speed_x = GPS_speed_x;
	packet.GPS_speed_y = GPS_speed_y;
	packet.GPS_heading = GPS_heading;
	packet.GPS_time_of_week = GPS_time_of_week;
	packet.GPS_latitude = GPS_latitude;
	packet.GPS_week = GPS_week;
	packet.GPS_status = GPS_status;
	packet.GPS_sat_num = GPS_sat_num;

        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 42);
#endif

	msg->msgid = MAVLINK_MSG_ID_ASCTEC_GPS;
	return mavlink_finalize_message(msg, system_id, component_id, 42, 248);
}

/**
 * @brief Pack a asctec_gps message on a channel
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param chan The MAVLink channel this message was sent over
 * @param msg The MAVLink message to compress the data into
 * @param msec Timestamp (microseconds since UNIX epoch or microseconds since system boot)
 * @param GPS_status GPS status information: Bit7...Bit3: 0; Bit 2: longitude direction; Bit1: latitude direction; Bit 0: GPS lock
 * @param GPS_latitude Latitude in degrees * 10^7
 * @param GPS_longitude Longitude in degrees * 10^7
 * @param GPS_height Altitude in mm
 * @param GPS_position_accuracy accuracy estimates in mm
 * @param GPS_height_accuracy accuracy estimates in mm
 * @param GPS_speed_x speed in x (E/W) in mm/s
 * @param GPS_speed_y speed in y (N/S) in mm/s
 * @param GPS_heading GPS heading in deg * 1000
 * @param GPS_sat_num number of satellites used in NAV solution
 * @param GPS_time_of_week [ms] (1 week = 604,800 s)
 * @param GPS_week starts from beginning of year 1980
 * @return length of the message in bytes (excluding serial stream start sign)
 */
static inline uint16_t mavlink_msg_asctec_gps_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
							   mavlink_message_t* msg,
						           uint32_t msec,uint8_t GPS_status,uint16_t GPS_latitude,int32_t GPS_longitude,int32_t GPS_height,uint32_t GPS_position_accuracy,uint32_t GPS_height_accuracy,int32_t GPS_speed_x,int32_t GPS_speed_y,int32_t GPS_heading,uint8_t GPS_sat_num,uint32_t GPS_time_of_week,uint16_t GPS_week)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
	char buf[42];
	_mav_put_uint32_t(buf, 0, msec);
	_mav_put_int32_t(buf, 4, GPS_longitude);
	_mav_put_int32_t(buf, 8, GPS_height);
	_mav_put_uint32_t(buf, 12, GPS_position_accuracy);
	_mav_put_uint32_t(buf, 16, GPS_height_accuracy);
	_mav_put_int32_t(buf, 20, GPS_speed_x);
	_mav_put_int32_t(buf, 24, GPS_speed_y);
	_mav_put_int32_t(buf, 28, GPS_heading);
	_mav_put_uint32_t(buf, 32, GPS_time_of_week);
	_mav_put_uint16_t(buf, 36, GPS_latitude);
	_mav_put_uint16_t(buf, 38, GPS_week);
	_mav_put_uint8_t(buf, 40, GPS_status);
	_mav_put_uint8_t(buf, 41, GPS_sat_num);

        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 42);
#else
	mavlink_asctec_gps_t packet;
	packet.msec = msec;
	packet.GPS_longitude = GPS_longitude;
	packet.GPS_height = GPS_height;
	packet.GPS_position_accuracy = GPS_position_accuracy;
	packet.GPS_height_accuracy = GPS_height_accuracy;
	packet.GPS_speed_x = GPS_speed_x;
	packet.GPS_speed_y = GPS_speed_y;
	packet.GPS_heading = GPS_heading;
	packet.GPS_time_of_week = GPS_time_of_week;
	packet.GPS_latitude = GPS_latitude;
	packet.GPS_week = GPS_week;
	packet.GPS_status = GPS_status;
	packet.GPS_sat_num = GPS_sat_num;

        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 42);
#endif

	msg->msgid = MAVLINK_MSG_ID_ASCTEC_GPS;
	return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 42, 248);
}

/**
 * @brief Encode a asctec_gps struct into a message
 *
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param msg The MAVLink message to compress the data into
 * @param asctec_gps C-struct to read the message contents from
 */
static inline uint16_t mavlink_msg_asctec_gps_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_asctec_gps_t* asctec_gps)
{
	return mavlink_msg_asctec_gps_pack(system_id, component_id, msg, asctec_gps->msec, asctec_gps->GPS_status, asctec_gps->GPS_latitude, asctec_gps->GPS_longitude, asctec_gps->GPS_height, asctec_gps->GPS_position_accuracy, asctec_gps->GPS_height_accuracy, asctec_gps->GPS_speed_x, asctec_gps->GPS_speed_y, asctec_gps->GPS_heading, asctec_gps->GPS_sat_num, asctec_gps->GPS_time_of_week, asctec_gps->GPS_week);
}

/**
 * @brief Send a asctec_gps message
 * @param chan MAVLink channel to send the message
 *
 * @param msec Timestamp (microseconds since UNIX epoch or microseconds since system boot)
 * @param GPS_status GPS status information: Bit7...Bit3: 0; Bit 2: longitude direction; Bit1: latitude direction; Bit 0: GPS lock
 * @param GPS_latitude Latitude in degrees * 10^7
 * @param GPS_longitude Longitude in degrees * 10^7
 * @param GPS_height Altitude in mm
 * @param GPS_position_accuracy accuracy estimates in mm
 * @param GPS_height_accuracy accuracy estimates in mm
 * @param GPS_speed_x speed in x (E/W) in mm/s
 * @param GPS_speed_y speed in y (N/S) in mm/s
 * @param GPS_heading GPS heading in deg * 1000
 * @param GPS_sat_num number of satellites used in NAV solution
 * @param GPS_time_of_week [ms] (1 week = 604,800 s)
 * @param GPS_week starts from beginning of year 1980
 */
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS

static inline void mavlink_msg_asctec_gps_send(mavlink_channel_t chan, uint32_t msec, uint8_t GPS_status, uint16_t GPS_latitude, int32_t GPS_longitude, int32_t GPS_height, uint32_t GPS_position_accuracy, uint32_t GPS_height_accuracy, int32_t GPS_speed_x, int32_t GPS_speed_y, int32_t GPS_heading, uint8_t GPS_sat_num, uint32_t GPS_time_of_week, uint16_t GPS_week)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
	char buf[42];
	_mav_put_uint32_t(buf, 0, msec);
	_mav_put_int32_t(buf, 4, GPS_longitude);
	_mav_put_int32_t(buf, 8, GPS_height);
	_mav_put_uint32_t(buf, 12, GPS_position_accuracy);
	_mav_put_uint32_t(buf, 16, GPS_height_accuracy);
	_mav_put_int32_t(buf, 20, GPS_speed_x);
	_mav_put_int32_t(buf, 24, GPS_speed_y);
	_mav_put_int32_t(buf, 28, GPS_heading);
	_mav_put_uint32_t(buf, 32, GPS_time_of_week);
	_mav_put_uint16_t(buf, 36, GPS_latitude);
	_mav_put_uint16_t(buf, 38, GPS_week);
	_mav_put_uint8_t(buf, 40, GPS_status);
	_mav_put_uint8_t(buf, 41, GPS_sat_num);

	_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ASCTEC_GPS, buf, 42, 248);
#else
	mavlink_asctec_gps_t packet;
	packet.msec = msec;
	packet.GPS_longitude = GPS_longitude;
	packet.GPS_height = GPS_height;
	packet.GPS_position_accuracy = GPS_position_accuracy;
	packet.GPS_height_accuracy = GPS_height_accuracy;
	packet.GPS_speed_x = GPS_speed_x;
	packet.GPS_speed_y = GPS_speed_y;
	packet.GPS_heading = GPS_heading;
	packet.GPS_time_of_week = GPS_time_of_week;
	packet.GPS_latitude = GPS_latitude;
	packet.GPS_week = GPS_week;
	packet.GPS_status = GPS_status;
	packet.GPS_sat_num = GPS_sat_num;

	_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ASCTEC_GPS, (const char *)&packet, 42, 248);
#endif
}

#endif

// MESSAGE ASCTEC_GPS UNPACKING


/**
 * @brief Get field msec from asctec_gps message
 *
 * @return Timestamp (microseconds since UNIX epoch or microseconds since system boot)
 */
static inline uint32_t mavlink_msg_asctec_gps_get_msec(const mavlink_message_t* msg)
{
	return _MAV_RETURN_uint32_t(msg,  0);
}

/**
 * @brief Get field GPS_status from asctec_gps message
 *
 * @return GPS status information: Bit7...Bit3: 0; Bit 2: longitude direction; Bit1: latitude direction; Bit 0: GPS lock
 */
static inline uint8_t mavlink_msg_asctec_gps_get_GPS_status(const mavlink_message_t* msg)
{
	return _MAV_RETURN_uint8_t(msg,  40);
}

/**
 * @brief Get field GPS_latitude from asctec_gps message
 *
 * @return Latitude in degrees * 10^7
 */
static inline uint16_t mavlink_msg_asctec_gps_get_GPS_latitude(const mavlink_message_t* msg)
{
	return _MAV_RETURN_uint16_t(msg,  36);
}

/**
 * @brief Get field GPS_longitude from asctec_gps message
 *
 * @return Longitude in degrees * 10^7
 */
static inline int32_t mavlink_msg_asctec_gps_get_GPS_longitude(const mavlink_message_t* msg)
{
	return _MAV_RETURN_int32_t(msg,  4);
}

/**
 * @brief Get field GPS_height from asctec_gps message
 *
 * @return Altitude in mm
 */
static inline int32_t mavlink_msg_asctec_gps_get_GPS_height(const mavlink_message_t* msg)
{
	return _MAV_RETURN_int32_t(msg,  8);
}

/**
 * @brief Get field GPS_position_accuracy from asctec_gps message
 *
 * @return accuracy estimates in mm
 */
static inline uint32_t mavlink_msg_asctec_gps_get_GPS_position_accuracy(const mavlink_message_t* msg)
{
	return _MAV_RETURN_uint32_t(msg,  12);
}

/**
 * @brief Get field GPS_height_accuracy from asctec_gps message
 *
 * @return accuracy estimates in mm
 */
static inline uint32_t mavlink_msg_asctec_gps_get_GPS_height_accuracy(const mavlink_message_t* msg)
{
	return _MAV_RETURN_uint32_t(msg,  16);
}

/**
 * @brief Get field GPS_speed_x from asctec_gps message
 *
 * @return speed in x (E/W) in mm/s
 */
static inline int32_t mavlink_msg_asctec_gps_get_GPS_speed_x(const mavlink_message_t* msg)
{
	return _MAV_RETURN_int32_t(msg,  20);
}

/**
 * @brief Get field GPS_speed_y from asctec_gps message
 *
 * @return speed in y (N/S) in mm/s
 */
static inline int32_t mavlink_msg_asctec_gps_get_GPS_speed_y(const mavlink_message_t* msg)
{
	return _MAV_RETURN_int32_t(msg,  24);
}

/**
 * @brief Get field GPS_heading from asctec_gps message
 *
 * @return GPS heading in deg * 1000
 */
static inline int32_t mavlink_msg_asctec_gps_get_GPS_heading(const mavlink_message_t* msg)
{
	return _MAV_RETURN_int32_t(msg,  28);
}

/**
 * @brief Get field GPS_sat_num from asctec_gps message
 *
 * @return number of satellites used in NAV solution
 */
static inline uint8_t mavlink_msg_asctec_gps_get_GPS_sat_num(const mavlink_message_t* msg)
{
	return _MAV_RETURN_uint8_t(msg,  41);
}

/**
 * @brief Get field GPS_time_of_week from asctec_gps message
 *
 * @return [ms] (1 week = 604,800 s)
 */
static inline uint32_t mavlink_msg_asctec_gps_get_GPS_time_of_week(const mavlink_message_t* msg)
{
	return _MAV_RETURN_uint32_t(msg,  32);
}

/**
 * @brief Get field GPS_week from asctec_gps message
 *
 * @return starts from beginning of year 1980
 */
static inline uint16_t mavlink_msg_asctec_gps_get_GPS_week(const mavlink_message_t* msg)
{
	return _MAV_RETURN_uint16_t(msg,  38);
}

/**
 * @brief Decode a asctec_gps message into a struct
 *
 * @param msg The message to decode
 * @param asctec_gps C-struct to decode the message contents into
 */
static inline void mavlink_msg_asctec_gps_decode(const mavlink_message_t* msg, mavlink_asctec_gps_t* asctec_gps)
{
#if MAVLINK_NEED_BYTE_SWAP
	asctec_gps->msec = mavlink_msg_asctec_gps_get_msec(msg);
	asctec_gps->GPS_longitude = mavlink_msg_asctec_gps_get_GPS_longitude(msg);
	asctec_gps->GPS_height = mavlink_msg_asctec_gps_get_GPS_height(msg);
	asctec_gps->GPS_position_accuracy = mavlink_msg_asctec_gps_get_GPS_position_accuracy(msg);
	asctec_gps->GPS_height_accuracy = mavlink_msg_asctec_gps_get_GPS_height_accuracy(msg);
	asctec_gps->GPS_speed_x = mavlink_msg_asctec_gps_get_GPS_speed_x(msg);
	asctec_gps->GPS_speed_y = mavlink_msg_asctec_gps_get_GPS_speed_y(msg);
	asctec_gps->GPS_heading = mavlink_msg_asctec_gps_get_GPS_heading(msg);
	asctec_gps->GPS_time_of_week = mavlink_msg_asctec_gps_get_GPS_time_of_week(msg);
	asctec_gps->GPS_latitude = mavlink_msg_asctec_gps_get_GPS_latitude(msg);
	asctec_gps->GPS_week = mavlink_msg_asctec_gps_get_GPS_week(msg);
	asctec_gps->GPS_status = mavlink_msg_asctec_gps_get_GPS_status(msg);
	asctec_gps->GPS_sat_num = mavlink_msg_asctec_gps_get_GPS_sat_num(msg);
#else
	memcpy(asctec_gps, _MAV_PAYLOAD(msg), 42);
#endif
}
